package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.declare.cebOrder.request.CebOrderQueryRequest;
import com.dwms.entity.declare.cebOrder.request.CebOrderRequest;
import com.dwms.entity.declare.cebOrder.response.CebOrderResponse;
import com.dwms.entity.declare.cebOrderReceipt.response.CebOrderReceiptResponse;
import com.dwms.feign.declare.CebOrderFeignClient;
import com.dwms.feign.declare.CebOrderReceiptFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: CebOrderController
 * @Description: CebOrder
 * @Create 2025-09-15 23:07:33
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "订单备案信息")
@RestController
@RequestMapping(value = "/declare/cebOrder")
@RequiredArgsConstructor
public class CebOrderController {

    private final HttpServletRequest request;
    private final CebOrderFeignClient cebOrderFeignClient;
    private final CebOrderReceiptFeignClient cebOrderReceiptFeignClient;

    /**
     * 修改
     *
     * @param cebOrderRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result update(@RequestBody CebOrderRequest cebOrderRequest) {
        WebUtil.getAdminRequest(request,cebOrderRequest);
        return cebOrderFeignClient.update(cebOrderRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebOrderResponse>> findPage(@RequestBody CebOrderQueryRequest query) {
        WebUtil.getAdminRequest(request,query);
        return cebOrderFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebOrderFeignClient.findById(query);
    }

    /**
     * 回执查询
     * @param query
     * @return
     */
    @Operation(summary = "回执查询")
    @PostMapping("/findByOrderId")
    public Result<List<CebOrderReceiptResponse>> findByOrderId(@RequestBody QueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return this.cebOrderReceiptFeignClient.findByOrderId(query);
    }

    /**
     * 申报
     *
     * @param query
     * @return
     */
    @Operation(summary = "申报")
    @PostMapping("/declare")
    public Result declare(@RequestBody QueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return this.cebOrderFeignClient.declare(query);
    }

}
